﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace HossMvp.Core
{
    public abstract class AbstractModelManager : IModelManager<AbstractModel/*, IContentProvider*/>
    {
        //public abstract AbstractModel Create(params object[] args);
        public abstract AbstractModel Create<T>(params object[] args) where T : AbstractModel;

        /// <summary>
        /// Removes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        public abstract void Remove(AbstractModel model);

        /// <summary>
        /// Clears all model in this instance.
        /// </summary>
        public abstract void Clear();

        /// <summary>
        /// Gets or sets the models.
        /// </summary>
        /// <value>
        /// The models.
        /// </value>
        public abstract IEnumerable<AbstractModel> Models { get; protected set; }

        /// <summary>
        /// Gets or sets the presenter.
        /// </summary>
        /// <value>
        /// The presenter.
        /// </value>
        public IPresenter<AbstractModelManager, AbstractViewManager> Presenter { get; set; }

        /// <summary>
        /// Gets the command.
        /// </summary>
        /// <param name="name">The command name.</param>
        /// <returns>The command</returns>
        public ICommand GetCommand(string name)
        {
            var command = this.Presenter.CommandProcessor.GetCommand(name);
            Debug.Assert(command != null, "command != null");
            return command;
        }
    }
}